package Class.Method.Recursion;

/**
 * Enjoy programming!!!
 * Time: 2021/11/7 -  15:16
 */
public class HanoiTower {
    static int i = 0;
    public static void main(String[] args){
        HanoiTower.move(3, 'A', 'B', 'C');
    }
    public static void move(int n, char a, char b, char c){//三个形参：原始柱子、可借助的柱子、终点柱子
        if (n == 1){
            System.out.println(a + "->" + c + "    移动了" + ++i + "次");
        }
        else{
            move(n - 1, a, c, b);
            System.out.println(a + "->" + c+ "    移动了" + ++i + "次");
            move(n - 1, b, a, c);
        }
    }
}
